<template>
  <div class="zero-search-pager" v-show="!hide">
    <section class="search-pager-warp">
      <div class="title">

        <span v-show="onBack"
              @click="onBack()"
              title="返回"
              class="pager-back-content">
          <span class="pager-back">
             <svg-icon name="svg-icon-back" :size="20" color="#398ee5"></svg-icon>
          </span>

          <span>返回</span>

          <el-divider direction="vertical" style="height: 16px; margin-bottom: 1px"/>
        </span>

        <slot name="title">
          {{ menuTitle }}
        </slot>

      </div>
      <div class="pager-wrap">
        <slot name="left">
        </slot>
      </div>
      <div class="tools-wrap">
        <div style="flex: 1 1 0%;display: flex;">
          <div class="tools-list">
            <slot name="tools">
            </slot>
          </div>
        </div>

      </div>
    </section>
  </div>
</template>

<script setup name="ZeroSearchPager">
import {useRoute} from "vue-router";
import {computed, useAttrs} from "vue";

const props = defineProps({
  hide: {
    type: Boolean,
    default: false
  }
})

const route = useRoute();
const attrs = useAttrs();

const menuTitle = computed(() => {
  return route.meta.title
})

const onBack = computed(() => {
  return attrs.onBack || null
})

</script>

<style scoped lang="scss">

.zero-search-pager {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: white;
  padding: 0px 16px 0px;
  box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);

  .search-pager-warp {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 4px 0;

    .title {
      white-space: nowrap;
      color: #333333;
      font-size: 14px;
      font-weight: bold;
      height: 28px;
      line-height: 28px;

      .pager-back-content {
        cursor: pointer;

        .pager-back {
          //font-size: 12px;
          vertical-align: -4px;
          padding-right: 6px;
          display: inline-block;

        }
      }

    }

    .pager-wrap {
      display: inline-block;
      padding-left: 24px;
      padding-right: 40px;
    }

    .tools-wrap {
      display: flex;
      -webkit-box-flex: 1;
      -ms-flex: 1;
      flex: 1;
      max-height: 24px;

      .tools-list {
        flex: 1 1 0%;
        display: flex;
        justify-content: flex-end;
        height: 24px;
        max-height: 24px;
      }
    }
  }


}


/*
enter-active 定义进入过渡的结束状态
leave-active 定义离开过渡的结束状态
 */
.fade-transform-leave-active,
.fade-transform-enter-active {
  transition: all 0.5s;
}

/*
enter定义进入过渡的开始状态
 */
.fade-transform-enter {
  opacity: 0;
  transform: translateX(-30px);
}

/*
leave-to离场动画结束后的状态
 */
.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}

</style>
